<template>
  <dialog-editor ref="dialog"></dialog-editor>
</template>

<script>
  import DialogEditor from '@/components/DialogEditor'
  import dialogMixins from '@/utils/commonDialogMixins'

  export default {
    mixins: [dialogMixins],
    components: {DialogEditor},
    data() {
      return {
        dataFormConfig: {
          id: {
            hidden: true
          },
          licensePlateNumber: {
            label: '车牌号',
            placeholder: '请输入车牌号'
          },
          tareWeight:{
            label: '皮重',
            placeholder: '皮重'
          },
          errorWeight:{
            label: '误差重量',
            placeholder: '误差重量'
          },
          clientId:{
            label: '客户',
            placeholder: '客户',
            type: 'list',
            list: []
          },
          remark: {
            label: '备注',
            inputType: 'textarea',
            placeholder: '请输入备注'
          },
          carSource: {
            label: '车辆来源',
            type: 'switch',
            activeValue: 1,
            inactiveValue: 0,
            default: 1
          },
          dispatchStatus: {
            label: '状态',
            type: 'switch',
            activeValue: 1,
            inactiveValue: 0,
            default: 1
          }
        }
      }
    },
    methods: {
      init(id,property, cb) {
        this.dataForm.id = id || 0
        this.$refs.dialog.initDialog({
          dataForm: this.dataForm,
          config: this.dataFormConfig,
          dataRule: this.getNeedDataRule('licensePlateNumber', 'status'),
          initApi: 'licenseApi/licensePlateInfoInfo',
          saveApi: 'licenseApi/saveLicensePlateInfo',
          updateApi: 'licenseApi/updateLicensePlateInfo',
          objectName: 'licensePlateInfo',
          submitCallback: cb
        })
        this.$nextTick(() => {
          if (!this.R.isNil(property)) {
            Object.keys(property).forEach((key) => {
              this.dataForm[key] = property[key]
            })
          }
        })
      }
    }
  }
</script>

